define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'record/index' + location.search,
                    // add_url: 'record/add',
                    // edit_url: 'record/edit',
                    // del_url: 'record/del',
                    // multi_url: 'record/multi',
                    table: 'record',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'title', title: __('Title'), operate: 'LIKE'},
                        {field: 'category_ids', title: __('Type'),searchList: Config.templatelist,operate: 'FIND_IN_SET', formatter: Table.api.formatter.label},
                        {field: 'username1', title: __('Username1'), operate: 'LIKE'},
                        {field: 'mobile1', title: __('Mobile1'), operate: 'LIKE'},
                        {field: 'username2', title: __('Username2'), operate: 'LIKE'},
                        {field: 'mobile2', title: __('Mobile2'), operate: 'LIKE'},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
                        {field: 'createtime', title: __('Createtime'),operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'signtime', title: __('Signtime'),operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                    ]
                ]
            });
         $(".search input").attr('placeholder','请输入搜索内容');
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
